package dgt;

public class ElementHelper {
	private String causa, 
		sentido, 
	//	poblacion, 
	//	provincia, 
		pkInicio, 
		pkFinal, 
		circulacion = "[]", 
		carretera, 
		tipoInci,
		longitud,
		latitud;
	
	
	public void handleKeyValue(String key, String value){
		//System.out.println("["+key+"] ["+value+"]");
		if("causa".equals(key)){
			causa = value;
		}else if("sentido".equals(key)){
			sentido = value.toLowerCase();
		/*}else if("poblacion".equals(key)){
			poblacion = value;
		}else if("provincia".equals(key)){
			provincia = value;*/
		}else if("pkIni".equals(key)){
			pkInicio = value;
		}else if("pkFinal".equals(key)){
			pkFinal = value;
		}else if("carretera".equals(key)){
			carretera = value;
		}else if("nivel".equals(key)){
			if("NEGRO".equals(value)){
				circulacion = "[X]";
			}else if("ROJO".equals(value)){
				circulacion = "[!!!]";
			}else if("AMARILLO".equals(value)){
				circulacion = "[!!]";
			}else if("VERDE".equals(value)){
				circulacion = "[!]";
			}
		}else if("tipoInci".equals(key)){
			tipoInci = value;
		}else if("lng".equals(key)){
			longitud = value;
		}else if("lat".equals(key)){
			latitud = value;
		}
	}
	
	public String generateName(){
		StringBuilder name = new StringBuilder(circulacion);
		if("".equals(causa)){
			name.append(tipoInci);
		}else{
			name.append(causa);
		}
		name.append('-').append(carretera).append("(Kms.").append(pkInicio).append('-').append(pkFinal).append(") ");
		name.append(sentido); //.append('-').append(poblacion).append('-').append(provincia);
		return name.toString();
	}
	
	public String generateCoords(){
		return longitud + ',' + latitud;
	}
}
